package com.grade.controller;

import com.grade.domain.Response;
import com.grade.domain.Student;
import com.grade.service.StudentService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")  // 允许跨域请求
public class StudentController {

    @Resource
    private StudentService studentService;

    // 查询所有学生的信息
    @RequestMapping("/student/page")
    public Response<List<Student>> getAllStudent(){
        // 调用服务层获取学生列表
        return studentService.getAllStudent();
    }

    // 添加学生
    @RequestMapping("/student/add")
    public Response<String> addStudent(@RequestBody Student student){
        // 调用服务层进行学生添加
        return studentService.addStudent(student);
    }
}
